package bagdto

import (
	"github.com/gogf/gf/v2/frame/g"
	"xr-game-server/core/constants/common"
	"xr-game-server/entity"
	"xr-game-server/module/protocol"
)

type GetBagReq struct {
	g.Meta `path:"/getBagCells" method:"post" summary:"获取背包数据" tags:"背包模块"`
}

func newBagCellDto(cell *entity.PlayerBag) *protocol.ItemModel {
	ret := &protocol.ItemModel{
		Id:  cell.CfgId,
		Val: cell.Val,
	}
	return ret
}

type GetBagRes struct {
	Data []*protocol.ItemModel
}

func NewGetBagRes(dbs []*entity.PlayerBag) *GetBagRes {
	ret := &GetBagRes{Data: make([]*protocol.ItemModel, common.Zero)}
	for _, db := range dbs {
		ret.Data = append(ret.Data, newBagCellDto(db))
	}
	return ret
}
